import axios from 'axios'
import { Notification } from 'element-ui';
// import vueRouter from 'vue-router'

let request = axios.create({
    // baseURL: 'http://192.168.200.251:8888/admin/user/list',
    timeout: 60000,
  })

  // 请求拦截
  // 发送请求时做的事情
  request.interceptors.request.use(config => {
    config.headers['Shopping-Admin-Token'] = sessionStorage.getItem('Shopping-Admin-Token')
    console.log('config', config)

    return config
  })

  // 返回拦截

  request.interceptors.response.use(response => {
    console.log('返回信息', response)

    if (response.data.errno === 501) {

        Notification.error({
            title: '请登录'
        })

        return Promise.reject('error')
    } else {
      return response
    }
  })

  export default request